/**
* @author attilax 1466519819@qq.com
* @version  c0
* Copyright 2013 attilax reserved.
* All content (including but not limited to text, pictures, etc.) have copyright restrictions, the note license.
* all the software source code  copyright belongs to the original owner.
* Creative Commons protocol use please follow the "sign for non-commercial use consistent"; we do not welcome the large-scale duplication, and all rights reserved.
* Commercial sites or unauthorized media may not copy software source code.
**/
 
 


 
package com.mijie.homi.search.dao.topic;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.mijie.core.IBatisDao;
import com.mijie.homi.search.domain.topic.Topic;
import com.mijie.homi.search.domain.topic.TopicOptions;

@Repository
/**
* @author attilax 1466519819@qq.com
* @version  c0
**/
public class TopicDao  extends IBatisDao{

/**
* @author attilax 1466519819@qq.com
* @version  c0
**/
	public Topic getTopicById(int id){
		return this.selectOne("getTopicById", id);
	}
	
/**
* @author attilax 1466519819@qq.com
* @version  c0
**/
	public List<TopicOptions> listOptions(int topicId){
		return this.selectList("listOptions", topicId);
	}
	
/**
* @author attilax 1466519819@qq.com
* @version  c0
**/
	public List<Topic> listTopic(int offset,int limit){
		Map<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return this.selectList("listTopic", parameter);
	}
	
/**
* @author attilax 1466519819@qq.com
* @version  c0
**/
	public List<Integer> listTopicFromTrash(){
		return this.selectIntList("listTopicFromTrash");
	}
	
/**
* @author attilax 1466519819@qq.com
* @version  c0
**/
	public int deleteTopicFromTrash(int id){
		return this.delete("deleteTopicFromTrash",id);
	}
	
/**
* @author attilax 1466519819@qq.com
* @version  c0
**/
	public int deleteTopic(int id){
		return this.delete("deleteTopic",id);
	}
	
/**
* @author attilax 1466519819@qq.com
* @version  c0
**/
	public int deleteOptions(int topicId){
		return this.delete("deleteOptions",topicId);
	}
	
/**
* @author attilax 1466519819@qq.com
* @version  c0
**/
	public List<Integer> listUserForTopicChoice(int topicId){
		return this.selectIntList("listUserForTopicChoice",topicId);
	}
	
/**
* @author attilax 1466519819@qq.com
* @version  c0
**/
	public int deleteRelatedTopic(int userId,int topicId){
		Map<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("userId", userId);
		parameter.put("topicId", topicId);
		return this.delete("deleteRelatedTopic",parameter);
	}
}